﻿using NHibernate;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WebSite.Core;
using WebSite.Data.NH.Infrastructure;
using WebSite.Model;
using NHibernate.Linq;

namespace WebSite.Data.NH.Repositories
{
    public interface IMoudleRepository : IRepository<MoudleInfo>
    {
        IList<MoudleInfo> GetAllMoudle(int companyId);
    }

    public class MoudleRepository : NhRepositoryBase<MoudleInfo>, IMoudleRepository
    {
        public MoudleRepository(ISession session)
            : base(session)
        {
        }

        public IList<MoudleInfo> GetAllMoudle(int companyId)
        {
            var query = GetMany(e => e.IsEnable == 1 && e.CompanyId == companyId, 1, 1000, new OrderByExpression<MoudleInfo, int>(e => e.Order));
            query = query.Cacheable();
            var list = query.ToList();
            return list;
        }
    }
}
